home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / System / XADmaster / xad_dev / Include / Autodocs / xadsub.doc < prev   
Encoding:
Text File  |  2001-04-01  |  17.0 KB  |  372 lines

  1. TABLE OF CONTENTS
  2.  
  3. xadForeman/--Overview--
  4. xadClient/--Overview--
  5. xadClient/xcFree
  6. xadClient/xcGetInfo
  7. xadClient/xcRecogData
  8. xadClient/xcUnArchive
  9.  
  10. VERSION
  11.         $VER: xadsub.doc 10.0 (25.02.2001) by SDI
  12.  
  13. xadForeman/--Overview--                               xadForeman/--Overview--
  14.  
  15. The xadForeman structure is just some kind of header for external clients.
  16. It protects the clients from being executed accidentally by having a small
  17. piece of code (MOVEQ #-1,d0 : RTS) in the first 4 bytes.
  18. The master can identify a valid bunch of external clients by checking the
  19. first hunk of a file for the foreman identification.
  20. Finally, a foreman holds the pointer to a linked list of clients and thus
  21. enables the master to work with these clients.
  22. The version entry of this structure specifies name and version of the file
  23. and not of the linked client list!
  24.  
  25. Multiple clients can be stored in the linked list of one file. This allows
  26. to use code by different clients. E.g. The normal archive and a SFX client
  27. both use nearly equal unarchiving code, but different recognition functions.
  28.  
  29. If the clients have no double useable code, it is better to distribute them
  30. in seperate files to allow better updating.
  31.  
  32. xadClient/--Overview--                                 xadClient/--Overview--
  33.  
  34. The xadClient structure is the heart of the whole library system. Each
  35. client enables the master to recognize and unarchive files.
  36.  
  37. Therefore each client contains 4 routines that are called from the master.
  38. Pointers to these are stored in xc_RecogData, xc_GetInfo, xc_UnArchive and
  39. xc_Free.
  40.  
  41. All routines have one thing in common: the CPU registers D0/D1/A0/A1 are
  42. so-called scratch registers, they may change during execution, all other
  43. registers must remain unchanged. CPU register A6 holds a pointer to the
  44. xadMasterBase structure. See chapters below for a description of the client
  45. routines.
  46.  
  47. ALL CLIENT ROUTINES MUST BE REENTRANT! NEVER STORE ANY DATA IN STATIC
  48. MEMORY AREAS, USE THE STACK OR SOME ALLOCATED MEMORY INSTEAD! REMEMBER THAT
  49. THE ROUTINES MIGHT BE CALLED BY SEVERAL PROGRAMS AT THE SAME TIME! DO
  50. NOT EXCEED STACK USAGE (1KB SHOULD BE THE MAXIMUM), AS PROGRAMS NORMALLY
  51. HAVE ONLY 4KB STACK.
  52.  
  53. The name of the archiver that is supported by the client and the flags that
  54. describe the packer are stored in xc_ArchiverName and xc_Flags. Internal
  55. clients all have an unique ID value stored in xc_Identifier. If you have
  56. written a client that should replace an internal one, because it is faster
  57. or otherwise enhanced, simply put the ID of the client to be replaced in
  58. xc_Identifier. The old client will then be taken out of the list of used
  59. clients. Normally this ID should be zero. There is one problem with this:
  60. When the user deactivates external clients the xadmaster system is missing
  61. this type completely as internal client is not activated in this case.
  62.  
  63. xcRecogData() usually only requires a quite small part of a file to
  64. recognize it properly. To avoid reading the whole file for recognition
  65. purposes, you need to set xc_RecogSize to the minimum amount of bytes
  66. that is required to recognize the crunched file correctly.
  67. Note that xadmaster uses this value internally to decide whether a file
  68. might be archived with a archiver or not, so you don't have to do an extra
  69. size comparison in your xc_RecogData function any more.
  70. For archiver headers with non-constant sizes, simply set xc_RecogSize
  71. to a value that will ensure correct recognition of all possible files.
  72.  
  73. Whenever you intend to use features of the xadmaster.library in your
  74. clients that are marked (V2) or higher, make sure to set xc_MasterVersion
  75. to the desired version number, otherwise an old library version might
  76. crash while using the new client.
  77.  
  78. Whenever a client calls a xadmaster function and gets a return code, the
  79. client needs to return this code! So whenever an error code is produced
  80. somewhere, it must reach the calling program. This is most important
  81. for progress report (automatically called by xadHookAccess), as the
  82. XADERR_SKIP can be checked by calling program.
  83.  
  84. ANY needed structure must be allocated with xadAllocObject! None of the
  85. XAD structures can be allocated any other way!
  86.  
  87. Multivolume support:
  88. This system also supports multivolume archives. A special multivolume
  89. input stream (XAD_INSPLITTED) allows to pass multiple input files as
  90. one stream to the clients. This means multivolume archiver files are
  91. passed as ONE stream to the related client. The client may check the
  92. ai->xai_MultiVolume entry. This is an ULONG array witch holds the start
  93. offset of every part and is finished with an zero value. Note that the
  94. first entry is a zero value as well in normal case. The client may
  95. expect the parts to be in correct order, but must handle missing or
  96. defective parts (Handling of defective archives is necessary for normal
  97. archives as well!). Do not rely to much on part size information, as
  98. missing parts or defective parts normally will destroy the usefulness
  99. of that size information.
  100.  
  101. Filesystem clients:
  102. Starting with (V5), the library supports external filesystem clients as
  103. well. These clients have no xc_RecogData function, but get called xc_GetInfo
  104. always. The fields xc_RecogSize is useless as well for these clients.
  105. Filesystem clients are called, when xadGetDiskInfo() and xadDiskFileUnArc()
  106. are called. They are skipped for xadGetInfo(). The functions are equal
  107. to normal clients, except that they handle filesystem images and no
  108. file archives.
  109.  
  110. Apple Macintosh support:
  111. When handling special Apple archives, handle data and resource fork as
  112. separate entries into xadFileInfo list, with some additional information.
  113.  
  114. The flag XADFIF_MACDATA flag implies:
  115. - This file IS a data fork.
  116. - This file CAN have a separate resource fork.
  117. - This file's xfi_Comment (if not NULL) can be read as "TYPE/CRTR" or
  118.   "TYPE/CRTR FLGS", where TYPE and CRTR are 4 character ASCII codes
  119.   detailing a file's file ID and creator ID, and FLGS is a 4 digit
  120.   hexadecimal number detailing Finder Flags, as defined by the field
  121.   'FInfo.fdFlags' in RFC 1740.
  122.   Any normal comment may be appended at the end seperated by a space
  123.   character. Use "????/???? 0000" as default in case the data is not
  124.   available, but a comment needs to be stored.
  125. - The entry xfi_MacFork is either NULL or a pointer to the resource fork
  126.   list entry.
  127.  
  128. The flag XADFIF_MACRESOURCE flag implies:
  129. - This file IS a resource fork.
  130. - Suggested filename is "<datafork name>.rsrc".
  131. - This file DOES have a separate data fork.
  132. - The entry xfi_MacFork is a pointer to the data fork list entry.
  133. - If the data fork is empty, do not create an entry for it, but
  134.   leave xfi_MacFork empty and store the comment in resource fork entry.
  135.  
  136. NOTE: The pointer xfi_MacFork points to a normal entry of the file
  137. information list! This pointer is only additional information to find
  138. corresponding entries.
  139.  
  140. xadClient/xcFree                                             xadClient/xcFree
  141.  
  142.    NAME
  143.         xcFree -- Free all resources allocated by xcGetInfo
  144.  
  145.    SYNOPSIS
  146.         xcFree(ai, xadMasterBase)
  147.                A0       A6
  148.  
  149.         void xcFree(struct xadArchiveInfo *, struct xadMasterBase *)
  150.  
  151.    FUNCTION
  152.         This function frees all the stuff allocated by xcGetInfo. It is
  153.         called after unsuccessful xcGetInfo as well, so you need not to
  154.         call any freeing functions there. But be prepared for that case.
  155.         You must check all entries, as xcGetInfo may fail in the first
  156.         allocation stages (f.e. allocation of xadDiskInfo or xadFileInfo
  157.         structures).
  158.         Clear all entries you have freed! There should not be any pointers
  159.         left in xadArchiveInfo structure which do not point to valid
  160.         memory.
  161.  
  162.         Starting with (V2) the master library can do some stuff for you.
  163.         This is always done after calling this function, so you have the
  164.         chance to do private stuff before!
  165.         If you set the flag XADCF_FREEFILEINFO in xc_Flags, the master
  166.         library parses the xai_FileInfo list and frees every entry.
  167.         If you set the flag XADCF_FREEDISKINFO in xc_Flags, the master
  168.         library parses the xai_DiskInfo list and frees every entry.
  169.         If you set the flag XADCF_FREETEXTINFO in xc_Flags, the master
  170.         library parses the xdi_TextInfo list of every xadDiskInfo
  171.         structure and frees every entry.
  172.         If you set the flag XADCF_FREETEXTINFOTEXT in xc_Flags, the
  173.         master library frees xti_Text entry of xadTextInfo structures.
  174.         This requires these entries to be allocated with xadAllocVec()
  175.         function.
  176.         If you set the flag XADCF_FREESKIPINFO with (V3) in xc_Flags, the
  177.         master library parses the xai_SkipInfo list and frees every entry.
  178.  
  179.         If your free function is empty, because all can be done by master
  180.         library, then you may place a zero in xc_Free field of xadClient
  181.         structure and remove the function totally.
  182.  
  183.    INPUTS
  184.         ai      the master communication structure
  185.  
  186.    SEE ALSO
  187.         Example sourcecodes, xadmaster.library/xadFreeInfo()
  188.  
  189. xadClient/xcGetInfo                                       xadClient/xcGetInfo
  190.  
  191.    NAME
  192.         xcGetInfo -- create all information about an archive file
  193.  
  194.    SYNOPSIS
  195.         result = xcGetInfo(ai, xadMasterBase)
  196.           D0               A0        A6
  197.  
  198.         LONG xcGetInfo(struct xadArchiveInfo *, struct xadMasterBase *)
  199.  
  200.    FUNCTION
  201.         This function is the most important one. It creates a structure
  202.         list containing all necessary information. File archivers create
  203.         a linked list of xadFileInfo structures for every file/link/
  204.         directory which is stored in the archive. xadAllocObject helps
  205.         to store that information by providing 3 tags for getting special
  206.         memory. XAD_OBJNAMESIZE can be used to allocate a buffer for
  207.         storing (also multiple) names. The buffer is byte aligned. Do not
  208.         forget to count the 0-byte for every string you want to store there.
  209.         The buffer pointer is stored in xfi_FileName.
  210.         XAD_OBJCOMMENTSIZE is equal to this, but stored in xfi_Comment.
  211.         For file and disk archives there is the flag XAD_OBJPRIVINFOSIZE,
  212.         which returns a longword aligned buffer in xfi_PrivateInfo or
  213.         xdi_PrivateInfo.
  214.         Disk archivers create a linked list of xadDiskInfo structures.
  215.         Normal disk archivers do not allow to store more than one archive,
  216.         so linking is most time not necessary, but it is supported.
  217.         When storing information texts, they must be finished with a zero
  218.         byte, which is not counted in size field!
  219.  
  220.         Every file or disk entry gets an entrynumber, which increases from
  221.         first to last entry. For mixed archivers this means that a
  222.         "file, disk, disk, file, file, disk" archive gets file entry
  223.         numbers 1,4,5 and disk entry numbers 2,3,6. The number for each
  224.         entry must be exactly the same, if the archive is reopened.
  225.         Most disk archivers are based on cylinder structure. These should
  226.         fill the xadDiskInfo fields correctly. If archivers are not based
  227.         on it (e.g. only sector based) they need to set XADDIF_NOCYLINDER
  228.         flag!
  229.         Starting with (V10) the functions xadAddFileEntry and xadAddDiskEntry
  230.         should be used to insert a new entry into the linked list. This
  231.         allows to use progress hooks and automatically sets correct
  232.         entry number. Always use the return value, as it may be XADERR_BREAK,
  233.         if user stopped processing! If possible the EXTRACTONBUILD flags can
  234.         be set and the entry maybe extracted directly after adding it. The
  235.         XAD_SETINPOS flag is useful to get correct file position in any case.
  236.  
  237.         If the archiver format does not support file dates, set the
  238.         current date (XAD_DATECURRENTTIME tag) and XADFIF_NODATE flag.
  239.         Protection bits default to zero (equals "rwed").
  240.         Archivers may store XADAIF_FILECORRUPT flag in xai_Flags, when 
  241.         archive is corrupt, but some entries are still usable. Unusable
  242.         entries must not appear in entry list. Do not return an error
  243.         code in that case, as an error code always means total failure.
  244.         Starting with V2, an error code may be stored in xai_LastError,
  245.         when XADAIF_FILECORRUPT is used.
  246.  
  247.         Starting with (V3), you may produce a linked list of xadSkipInfo
  248.         structures. The entries must not overlap and there must be at
  249.         least one byte between entries!
  250.         This forces the xadHookTagAccess() function to skip these parts
  251.         for read, copy and input seek operations, when XAD_USESKIPINFO
  252.         tag is used.
  253.  
  254.     The system can handle single crunched files also. These are handled
  255.     as if they where file archives. Set XADFIF_NOFILENAME or
  256.     XADFIF_NOUNCRUNCHSIZE if necessary. In case you set
  257.     XADFIF_NOFILENAME, you should store xadMasterBase->xmb_DefaultName
  258.     as filename. Starting with V7 the master library supplies the
  259.     input name in xai_InName (only if available). This can be used for
  260.     name creation also. You need to allocate name space and copy (and
  261.     modify) that name, as the pointer does not stay valid after leaving
  262.     xcGetInfo().
  263.  
  264.     Filesystem clients need to return XADERR_FILESYSTEM, if the type
  265.     is totally unknown. Else they will break the scanning for other
  266.     filesystems. Do not return any other return codes (except produced
  267.     by low memory or input errors), before you have validated the file
  268.     type. The file list created by filesystems is sorted by name after
  269.     return of xcGetInfo() and the entry numbers are set according to
  270.     new position.
  271.  
  272.    INPUTS
  273.         ai      master communication structure
  274.  
  275.    RESULT
  276.         result  - any of the XADERR codes or zero when all is ok.
  277.  
  278.    SEE ALSO
  279.         Example sourcecodes, xadmaster.library/xadGetInfo()
  280.  
  281. xadClient/xcRecogData                                   xadClient/xcRecogData
  282.  
  283.    NAME
  284.         xcRecogData -- Scan input buffer for known archiver type
  285.  
  286.    SYNOPSIS
  287.         result = xcRecogData(size, buffer, xadMasterBase)
  288.           D0                  D0     A0         A6
  289.  
  290.         BOOL xcRecogData(ULONG, STRPTR, struct xadMasterBase *)
  291.  
  292.    FUNCTION
  293.         Returns non zero when this buffer is part of a archive file
  294.         supported by this client. The recognition should be very stable.
  295.         It should be tested with lots of files. One wrong recognition
  296.         for 100000 files is acceptable.
  297.  
  298.     The minimum size needed for recognition (stored in xadClient
  299.     structure) should not be larger than 1024 bytes if possible.
  300.     Remember, that the master library needs to allocate recognition
  301.     buffers with largest size found in all clients. Scanning archives
  302.     is slowed down, if this size is too large!
  303.  
  304.     This function does not exists for filesystem clients (set its pointer
  305.     to 0).
  306.  
  307.     If you set XADCF_NOCHECKSIZE in client structure, this function is
  308.     also called for buffers shorter than the minimum size specified in
  309.     client structure. This is useful for archiver formats, which have
  310.     different sizes and hard detection schemes (e.g. EXE and SFX types).
  311.     You need to do minimum checks yourself: The minimum passed size may
  312.     be zero (empty file!). Do not read behind buffer borders in any case.
  313.  
  314.    INPUTS
  315.         size    size of passed buffer
  316.         buffer  buffer containing start of file to scan
  317.  
  318.    RESULT
  319.         result - TRUE if archiver is recogniced, FALSE if not
  320.  
  321.    SEE ALSO
  322.         Example sourcecodes, xadmaster.library/xadRecogFile(),
  323.         xadmaster.library/xadGetInfo()
  324.  
  325. xadClient/xcUnArchive                                   xadClient/xcUnArchive
  326.  
  327.    NAME
  328.         xcUnArchive -- write the required entry to destination
  329.  
  330.    SYNOPSIS
  331.         result = xcUnArchive(ai, xadMasterBase)
  332.           D0                 A0        A6
  333.  
  334.         LONG xcUnArchive(struct xadArchiveInfo *, struct xadMasterBase *)
  335.  
  336.    FUNCTION
  337.         This function dearchives one entry. The required entry is passed
  338.         in xai_CurFile or xai_CurDisk. A normal client will support only
  339.         one of the two possibilities, but clients using file and/or disk
  340.         archives are allowed as well. When writing disk data, the client
  341.         should write data in blocks with size of multiple sectorsize.
  342.         Although it should work, it is not recommended to write blocks
  343.         unequal to this.
  344.         Nearly all information you may need is stored in xadArchiveInfo
  345.         structure.
  346.         You may expect the entries to be unarchived in same order as they
  347.         are numbered, but it is not necessary! So be prepared to restart
  348.         decrunching for archivers using blocks or merge methods.
  349.         Disk archivers may expect to be called again to dearchive an
  350.         entry, even if there is only one! So restore the file position
  351.         you need to unarchive.
  352.  
  353.         When XADFIF_SEEKDATAPOS (file archive) or XADDIF_SEEKDATAPOS (disk
  354.         archive) is set, the master automatically seeks to the position in
  355.         xfi_DataPos or xdi_DataPos (V3).
  356.  
  357.         Starting with (V3), a linked list of xadSkipInfo structures
  358.         forces the xadHookTagAccess() function to skip these parts
  359.         for read, copy and input seek operations, when XAD_USESKIPINFO
  360.         tag is used.
  361.  
  362.    INPUTS
  363.         ai      master communication structure
  364.  
  365.    RESULT
  366.         result  - any of the XADERR codes or zero when all is ok.
  367.  
  368.    SEE ALSO
  369.         Example sourcecodes, xadmaster.library/xadDiskunArc(),
  370.         xadmaster.library/xadFileUnArc()
  371.  
  372.